package GoogleServices;

import java.net.MalformedURLException;
import java.net.URL;

import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.util.AuthenticationException;

/**
 * 
 * @author Rino
 * 
 *	Classe che gestisce l' autenticazione al nostro sistema ed inizializza i
 *	servizi google
 */
public abstract class GoogleServices {
	
	ContactsService contactsService;
	CalendarService calendarService;
	URL feedUrlContact;
	URL feedUrlContactBatch;
	URL feedUrlCalendar;
	
	
	public GoogleServices(String username, String password) throws AuthenticationException {
		
		contactsService = new ContactsService("Sistemintelligenti");
		calendarService = new CalendarService("Sistemintelligenti");
		
			contactsService.setUserCredentials(username, password);
			calendarService.setUserCredentials(username, password);
	
		try {
			
			feedUrlCalendar = new URL("http://www.google.com/calendar/feeds/"+username+"/private/full");
			
			feedUrlContact = new URL("https://www.google.com/m8/feeds/contacts/"+username+"/full");
		
			feedUrlContactBatch = new URL("https://www.google.com/m8/feeds/contacts/"+username+"/full/batch");
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
